<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Inflector</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Inflector</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/rails/activesupport/lib/active_support/inflector_rb.html">
                vendor/rails/activesupport/lib/active_support/inflector.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The <a href="Inflector.html">Inflector</a> transforms words from singular
to plural, class names to table names, modularized class names to ones
without, and class names to foreign keys. The default <a
href="Inflector.html#M001616">inflections</a> for pluralization,
singularization, and uncountable words are kept in inflections.rb.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001619">camelize</a>&nbsp;&nbsp;
      <a href="#M001626">classify</a>&nbsp;&nbsp;
      <a href="#M001628">constantize</a>&nbsp;&nbsp;
      <a href="#M001622">dasherize</a>&nbsp;&nbsp;
      <a href="#M001624">demodulize</a>&nbsp;&nbsp;
      <a href="#M001627">foreign_key</a>&nbsp;&nbsp;
      <a href="#M001623">humanize</a>&nbsp;&nbsp;
      <a href="#M001616">inflections</a>&nbsp;&nbsp;
      <a href="#M001629">ordinalize</a>&nbsp;&nbsp;
      <a href="#M001617">pluralize</a>&nbsp;&nbsp;
      <a href="#M001618">singularize</a>&nbsp;&nbsp;
      <a href="#M001625">tableize</a>&nbsp;&nbsp;
      <a href="#M001620">titleize</a>&nbsp;&nbsp;
      <a href="#M001621">underscore</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Class <a href="Inflector/Inflections.html" class="link">Inflector::Inflections</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001619" class="method-detail">
        <a name="M001619"></a>

        <div class="method-heading">
          <a href="#M001619" class="method-signature">
          <span class="method-name">camelize</span><span class="method-args">(lower_case_and_underscored_word, first_letter_in_uppercase = true)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
By default, <a href="Inflector.html#M001619">camelize</a> converts strings
to UpperCamelCase. If the argument to <a
href="Inflector.html#M001619">camelize</a> is set to &quot;:lower&quot;
then <a href="Inflector.html#M001619">camelize</a> produces lowerCamelCase.
</p>
<p>
<a href="Inflector.html#M001619">camelize</a> will also convert
&#8217;/&#8217; to &#8217;::&#8217; which is useful for converting paths to
namespaces
</p>
<p>
Examples
</p>
<pre>
  &quot;active_record&quot;.camelize #=&gt; &quot;ActiveRecord&quot;
  &quot;active_record&quot;.camelize(:lower) #=&gt; &quot;activeRecord&quot;
  &quot;active_record/errors&quot;.camelize #=&gt; &quot;ActiveRecord::Errors&quot;
  &quot;active_record/errors&quot;.camelize(:lower) #=&gt; &quot;activeRecord::Errors&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001619-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001619-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 147</span>
147:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">camelize</span>(<span class="ruby-identifier">lower_case_and_underscored_word</span>, <span class="ruby-identifier">first_letter_in_uppercase</span> = <span class="ruby-keyword kw">true</span>)
148:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">first_letter_in_uppercase</span>
149:       <span class="ruby-identifier">lower_case_and_underscored_word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\/(.?)/</span>) { <span class="ruby-value str">&quot;::&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">upcase</span> }.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/(^|_)(.)/</span>) { <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">upcase</span> }
150:     <span class="ruby-keyword kw">else</span>
151:       <span class="ruby-identifier">lower_case_and_underscored_word</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">camelize</span>(<span class="ruby-identifier">lower_case_and_underscored_word</span>)[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
152:     <span class="ruby-keyword kw">end</span>
153:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001626" class="method-detail">
        <a name="M001626"></a>

        <div class="method-heading">
          <a href="#M001626" class="method-signature">
          <span class="method-name">classify</span><span class="method-args">(table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Create a class name from a table name like <a href="Rails.html">Rails</a>
does for table names to models. Note that this returns a string and not a
Class. (To convert to an actual class follow <a
href="Inflector.html#M001626">classify</a> with <a
href="Inflector.html#M001628">constantize</a>.)
</p>
<p>
Examples
</p>
<pre>
  &quot;egg_and_hams&quot;.classify #=&gt; &quot;EggAndHam&quot;
  &quot;post&quot;.classify #=&gt; &quot;Post&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001626-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001626-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 228</span>
228:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">classify</span>(<span class="ruby-identifier">table_name</span>)
229:     <span class="ruby-comment cmt"># strip out any leading schema name</span>
230:     <span class="ruby-identifier">camelize</span>(<span class="ruby-identifier">singularize</span>(<span class="ruby-identifier">table_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/.*\./</span>, <span class="ruby-value str">''</span>)))
231:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001628" class="method-detail">
        <a name="M001628"></a>

        <div class="method-heading">
          <a href="#M001628" class="method-signature">
          <span class="method-name">constantize</span><span class="method-args">(camel_cased_word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Constantize tries to find a declared constant with the name specified in
the string. It raises a NameError when the name is not in CamelCase or is
not initialized.
</p>
<p>
Examples
</p>
<pre>
  &quot;Module&quot;.constantize #=&gt; Module
  &quot;Class&quot;.constantize #=&gt; Class
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001628-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001628-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 252</span>
252:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">constantize</span>(<span class="ruby-identifier">camel_cased_word</span>)
253:     <span class="ruby-keyword kw">unless</span> <span class="ruby-regexp re">/\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">camel_cased_word</span>
254:       <span class="ruby-identifier">raise</span> <span class="ruby-constant">NameError</span>, <span class="ruby-node">&quot;#{camel_cased_word.inspect} is not a valid constant name!&quot;</span>
255:     <span class="ruby-keyword kw">end</span>
256: 
257:     <span class="ruby-constant">Object</span>.<span class="ruby-identifier">module_eval</span>(<span class="ruby-node">&quot;::#{$1}&quot;</span>, <span class="ruby-keyword kw">__FILE__</span>, <span class="ruby-keyword kw">__LINE__</span>)
258:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001622" class="method-detail">
        <a name="M001622"></a>

        <div class="method-heading">
          <a href="#M001622" class="method-signature">
          <span class="method-name">dasherize</span><span class="method-args">(underscored_word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Replaces underscores with dashes in the string.
</p>
<p>
Example
</p>
<pre>
  &quot;puni_puni&quot; #=&gt; &quot;puni-puni&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001622-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001622-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 187</span>
187:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dasherize</span>(<span class="ruby-identifier">underscored_word</span>)
188:     <span class="ruby-identifier">underscored_word</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/_/</span>, <span class="ruby-value str">'-'</span>)
189:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001624" class="method-detail">
        <a name="M001624"></a>

        <div class="method-heading">
          <a href="#M001624" class="method-signature">
          <span class="method-name">demodulize</span><span class="method-args">(class_name_in_module)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Removes the module part from the expression in the string
</p>
<p>
Examples
</p>
<pre>
  &quot;ActiveRecord::CoreExtensions::String::Inflections&quot;.demodulize #=&gt; &quot;Inflections&quot;
  &quot;Inflections&quot;.demodulize #=&gt; &quot;Inflections&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001624-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001624-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 206</span>
206:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">demodulize</span>(<span class="ruby-identifier">class_name_in_module</span>)
207:     <span class="ruby-identifier">class_name_in_module</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^.*::/</span>, <span class="ruby-value str">''</span>)
208:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001627" class="method-detail">
        <a name="M001627"></a>

        <div class="method-heading">
          <a href="#M001627" class="method-signature">
          <span class="method-name">foreign_key</span><span class="method-args">(class_name, separate_class_name_and_id_with_underscore = true)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates a foreign key name from a class name.
<tt>separate_class_name_and_id_with_underscore</tt> sets whether the method
should put &#8216;_&#8217; between the name and &#8216;id&#8217;.
</p>
<p>
Examples
</p>
<pre>
  &quot;Message&quot;.foreign_key #=&gt; &quot;message_id&quot;
  &quot;Message&quot;.foreign_key(false) #=&gt; &quot;messageid&quot;
  &quot;Admin::Post&quot;.foreign_key #=&gt; &quot;post_id&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001627-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001627-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 241</span>
241:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">foreign_key</span>(<span class="ruby-identifier">class_name</span>, <span class="ruby-identifier">separate_class_name_and_id_with_underscore</span> = <span class="ruby-keyword kw">true</span>)
242:     <span class="ruby-identifier">underscore</span>(<span class="ruby-identifier">demodulize</span>(<span class="ruby-identifier">class_name</span>)) <span class="ruby-operator">+</span> (<span class="ruby-identifier">separate_class_name_and_id_with_underscore</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;_id&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;id&quot;</span>)
243:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001623" class="method-detail">
        <a name="M001623"></a>

        <div class="method-heading">
          <a href="#M001623" class="method-signature">
          <span class="method-name">humanize</span><span class="method-args">(lower_case_and_underscored_word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Capitalizes the first word and turns underscores into spaces and strips
_id. Like <a href="Inflector.html#M001620">titleize</a>, this is meant for
creating pretty output.
</p>
<p>
Examples
</p>
<pre>
  &quot;employee_salary&quot; #=&gt; &quot;Employee salary&quot;
  &quot;author_id&quot; #=&gt; &quot;Author&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001623-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001623-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 197</span>
197:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">humanize</span>(<span class="ruby-identifier">lower_case_and_underscored_word</span>)
198:     <span class="ruby-identifier">lower_case_and_underscored_word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/_id$/</span>, <span class="ruby-value str">&quot;&quot;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/_/</span>, <span class="ruby-value str">&quot; &quot;</span>).<span class="ruby-identifier">capitalize</span>
199:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001616" class="method-detail">
        <a name="M001616"></a>

        <div class="method-heading">
          <a href="#M001616" class="method-signature">
          <span class="method-name">inflections</span><span class="method-args">() {|Inflections.instance| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001616-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001616-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 89</span>
89:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inflections</span>
90:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
91:       <span class="ruby-keyword kw">yield</span> <span class="ruby-constant">Inflections</span>.<span class="ruby-identifier">instance</span>
92:     <span class="ruby-keyword kw">else</span>
93:       <span class="ruby-constant">Inflections</span>.<span class="ruby-identifier">instance</span>
94:     <span class="ruby-keyword kw">end</span>
95:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001629" class="method-detail">
        <a name="M001629"></a>

        <div class="method-heading">
          <a href="#M001629" class="method-signature">
          <span class="method-name">ordinalize</span><span class="method-args">(number)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Ordinalize turns a number into an ordinal string used to denote the
position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
</p>
<p>
Examples
</p>
<pre>
  ordinalize(1)     # =&gt; &quot;1st&quot;
  ordinalize(2)     # =&gt; &quot;2nd&quot;
  ordinalize(1002)  # =&gt; &quot;1002nd&quot;
  ordinalize(1003)  # =&gt; &quot;1003rd&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001629-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001629-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 268</span>
268:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ordinalize</span>(<span class="ruby-identifier">number</span>)
269:     <span class="ruby-keyword kw">if</span> (<span class="ruby-value">11</span><span class="ruby-operator">..</span><span class="ruby-value">13</span>).<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">%</span> <span class="ruby-value">100</span>)
270:       <span class="ruby-node">&quot;#{number}th&quot;</span>
271:     <span class="ruby-keyword kw">else</span>
272:       <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">%</span> <span class="ruby-value">10</span>
273:         <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>; <span class="ruby-node">&quot;#{number}st&quot;</span>
274:         <span class="ruby-keyword kw">when</span> <span class="ruby-value">2</span>; <span class="ruby-node">&quot;#{number}nd&quot;</span>
275:         <span class="ruby-keyword kw">when</span> <span class="ruby-value">3</span>; <span class="ruby-node">&quot;#{number}rd&quot;</span>
276:         <span class="ruby-keyword kw">else</span>    <span class="ruby-node">&quot;#{number}th&quot;</span>
277:       <span class="ruby-keyword kw">end</span>
278:     <span class="ruby-keyword kw">end</span>
279:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001617" class="method-detail">
        <a name="M001617"></a>

        <div class="method-heading">
          <a href="#M001617" class="method-signature">
          <span class="method-name">pluralize</span><span class="method-args">(word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the plural form of the word in the string.
</p>
<p>
Examples
</p>
<pre>
  &quot;post&quot;.pluralize #=&gt; &quot;posts&quot;
  &quot;octopus&quot;.pluralize #=&gt; &quot;octopi&quot;
  &quot;sheep&quot;.pluralize #=&gt; &quot;sheep&quot;
  &quot;words&quot;.pluralize #=&gt; &quot;words&quot;
  &quot;the blue mailman&quot;.pluralize #=&gt; &quot;the blue mailmen&quot;
  &quot;CamelOctopus&quot;.pluralize #=&gt; &quot;CamelOctopi&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001617-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001617-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 106</span>
106:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pluralize</span>(<span class="ruby-identifier">word</span>)
107:     <span class="ruby-identifier">result</span> = <span class="ruby-identifier">word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
108: 
109:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">word</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">uncountables</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">downcase</span>)
110:       <span class="ruby-identifier">result</span>
111:     <span class="ruby-keyword kw">else</span>
112:       <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">plurals</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>)<span class="ruby-operator">|</span> <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>) }
113:       <span class="ruby-identifier">result</span>
114:     <span class="ruby-keyword kw">end</span>
115:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001618" class="method-detail">
        <a name="M001618"></a>

        <div class="method-heading">
          <a href="#M001618" class="method-signature">
          <span class="method-name">singularize</span><span class="method-args">(word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The reverse of <a href="Inflector.html#M001617">pluralize</a>, returns the
singular form of a word in a string.
</p>
<p>
Examples
</p>
<pre>
  &quot;posts&quot;.singularize #=&gt; &quot;post&quot;
  &quot;octopi&quot;.singularize #=&gt; &quot;octopus&quot;
  &quot;sheep&quot;.singluarize #=&gt; &quot;sheep&quot;
  &quot;word&quot;.singluarize #=&gt; &quot;word&quot;
  &quot;the blue mailmen&quot;.singularize #=&gt; &quot;the blue mailman&quot;
  &quot;CamelOctopi&quot;.singularize #=&gt; &quot;CamelOctopus&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001618-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001618-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 126</span>
126:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">singularize</span>(<span class="ruby-identifier">word</span>)
127:     <span class="ruby-identifier">result</span> = <span class="ruby-identifier">word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
128: 
129:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">uncountables</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">result</span>.<span class="ruby-identifier">downcase</span>)
130:       <span class="ruby-identifier">result</span>
131:     <span class="ruby-keyword kw">else</span>
132:       <span class="ruby-identifier">inflections</span>.<span class="ruby-identifier">singulars</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>)<span class="ruby-operator">|</span> <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-identifier">replacement</span>) }
133:       <span class="ruby-identifier">result</span>
134:     <span class="ruby-keyword kw">end</span>
135:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001625" class="method-detail">
        <a name="M001625"></a>

        <div class="method-heading">
          <a href="#M001625" class="method-signature">
          <span class="method-name">tableize</span><span class="method-args">(class_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Create the name of a table like <a href="Rails.html">Rails</a> does for
models to table names. This method uses the <a
href="Inflector.html#M001617">pluralize</a> method on the last word in the
string.
</p>
<p>
Examples
</p>
<pre>
  &quot;RawScaledScorer&quot;.tableize #=&gt; &quot;raw_scaled_scorers&quot;
  &quot;egg_and_ham&quot;.tableize #=&gt; &quot;egg_and_hams&quot;
  &quot;fancyCategory&quot;.tableize #=&gt; &quot;fancy_categories&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001625-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001625-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 217</span>
217:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tableize</span>(<span class="ruby-identifier">class_name</span>)
218:     <span class="ruby-identifier">pluralize</span>(<span class="ruby-identifier">underscore</span>(<span class="ruby-identifier">class_name</span>))
219:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001620" class="method-detail">
        <a name="M001620"></a>

        <div class="method-heading">
          <a href="#M001620" class="method-signature">
          <span class="method-name">titleize</span><span class="method-args">(word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Capitalizes all the words and replaces some characters in the string to
create a nicer looking title. Titleize is meant for creating pretty output.
It is not used in the <a href="Rails.html">Rails</a> internals.
</p>
<p>
<a href="Inflector.html#M001620">titleize</a> is also aliased as as
titlecase
</p>
<p>
Examples
</p>
<pre>
  &quot;man from the boondocks&quot;.titleize #=&gt; &quot;Man From The Boondocks&quot;
  &quot;x-men: the last stand&quot;.titleize #=&gt; &quot;X Men: The Last Stand&quot;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001620-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001620-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 164</span>
164:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">titleize</span>(<span class="ruby-identifier">word</span>)
165:     <span class="ruby-identifier">humanize</span>(<span class="ruby-identifier">underscore</span>(<span class="ruby-identifier">word</span>)).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\b([a-z])/</span>) { <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">capitalize</span> }
166:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001621" class="method-detail">
        <a name="M001621"></a>

        <div class="method-heading">
          <a href="#M001621" class="method-signature">
          <span class="method-name">underscore</span><span class="method-args">(camel_cased_word)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The reverse of <tt><a href="Inflector.html#M001619">camelize</a></tt>.
Makes an underscored form from the expression in the string.
</p>
<p>
Changes &#8217;::&#8217; to &#8217;/&#8217; to convert namespaces to paths.
</p>
<p>
Examples
</p>
<pre>
  &quot;ActiveRecord&quot;.underscore #=&gt; &quot;active_record&quot;
  &quot;ActiveRecord::Errors&quot;.underscore #=&gt; active_record/errors
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001621-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001621-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/inflector.rb, line 175</span>
175:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">underscore</span>(<span class="ruby-identifier">camel_cased_word</span>)
176:     <span class="ruby-identifier">camel_cased_word</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/::/</span>, <span class="ruby-value str">'/'</span>).
177:       <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([A-Z]+)([A-Z][a-z])/</span>,<span class="ruby-value str">'\1_\2'</span>).
178:       <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/([a-z\d])([A-Z])/</span>,<span class="ruby-value str">'\1_\2'</span>).
179:       <span class="ruby-identifier">tr</span>(<span class="ruby-value str">&quot;-&quot;</span>, <span class="ruby-value str">&quot;_&quot;</span>).
180:       <span class="ruby-identifier">downcase</span>
181:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>